import tensorflow as tf

x = tf.constant([[4.,2.,3.], [2.,2.,3.]])
# print(tf.reduce_mean(x))    # tf.Tensor(2.6666667, shape=(), dtype=float32)
# print(tf.reduce_mean(x, axis=1))    # tf.Tensor([3. 2.3333333], shape=(2,), dtype=float32)

rank_3_tensor = tf.constant([[[4., 7.],[2., 5.],[3., 4.]], [[2., 6.], [2., 1.], [3., 2.]]])
print(tf.reduce_mean(rank_3_tensor, axis=2))

# 从合理计算的角度看，reduce_mean的axis，应当总是最后一个轴：相当于将最后一个轴消掉